package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.mapper.DtsRegionMapper;
import com.qf.pojo.DtsAddress;
import com.qf.pojo.DtsRegion;
import com.qf.service.RegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Service
public class RegionServiceImpl implements RegionService {
    @Autowired
    private DtsRegionMapper dtsRegionMapper;


    @Override
    public IPage<DtsRegion> findListByQuery(Integer page, Integer limit, String name, Integer code, String sort, String order) {
        return dtsRegionMapper.selectPage(new Page<>(page,limit),new QueryWrapper<DtsRegion>()
                .like(!StringUtils.isEmpty(name),"name",name)
                .eq(code!=null,"code",code)
                .orderBy(!StringUtils.isEmpty(sort),"ASC".equalsIgnoreCase(order),sort));
    }
}
